package chapter02

import java.io.{File, FileWriter, PrintWriter}
import scala.io.Source

/**
 *
 * @author cdhuangchao3
 * @date 2023/6/3 8:19 PM
 */
object Test06_FileIO {
  def main(args: Array[String]): Unit = {
    // 从文件中读取数据
    Source.fromFile("files/aa.txt").foreach(print)

    val file = new File("output/aa.txt")
    if (!file.exists()) {
      file.getParentFile.mkdirs()
      file.createNewFile()
    }
    val writer = new PrintWriter(new FileWriter(file))
    writer.write("abcde")
    writer.flush()
    writer.close()
  }

}
